GtkStyle *previous_style);
static void gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
-static gint gtk_label_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gint gtk_label_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction);
widget_class->style_set = gtk_label_style_set;
widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->direction_changed = gtk_label_direction_changed;
- widget_class->expose_event = gtk_label_expose;
+ widget_class->draw = gtk_label_draw;
widget_class->realize = gtk_label_realize;
widget_class->unrealize = gtk_label_unrealize;
widget_class->map = gtk_label_map;
static void
draw_insertion_cursor (GtkLabel *label,
+ cairo_t *cr,
GdkRectangle *cursor_location,
gboolean is_primary,
PangoDirection direction,
gboolean draw_arrow)
{
GtkWidget *widget = GTK_WIDGET (label);
- GtkAllocation allocation;
GtkTextDirection text_dir;
if (direction == PANGO_DIRECTION_LTR)
else
text_dir = GTK_TEXT_DIR_RTL;
- gtk_widget_get_allocation (widget, &allocation);
- gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget),
- &allocation, cursor_location,
+ gtk_cairo_draw_insertion_cursor (widget, cr, cursor_location,
is_primary, text_dir, draw_arrow);
}
}
static void
-gtk_label_draw_cursor (GtkLabel *label, gint xoffset, gint yoffset)
+gtk_label_draw_cursor (GtkLabel *label, cairo_t *cr, gint xoffset, gint yoffset)
{
GtkLabelPrivate *priv = label->priv;
GtkWidget *widget;
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor1->height);
- draw_insertion_cursor (label,
+ draw_insertion_cursor (label, cr,
&cursor_location, TRUE, dir1,
dir2 != PANGO_DIRECTION_NEUTRAL);
cursor_location.width = 0;
cursor_location.height = PANGO_PIXELS (cursor2->height);
- draw_insertion_cursor (label,
+ draw_insertion_cursor (label, cr,
&cursor_location, FALSE, dir2,
TRUE);
}
}
static gint
-gtk_label_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_label_draw (GtkWidget *widget,
+ cairo_t *cr)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
GtkLabelSelectionInfo *info = priv->select_info;
+ GtkAllocation allocation;
GtkStyle *style;
GdkWindow *window;
gint x, y;
gtk_label_ensure_layout (label, FALSE);
- if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
- priv->text && (*priv->text != '\0'))
+ if (priv->text && (*priv->text != '\0'))
{
get_layout_location (label, &x, &y);
style = gtk_widget_get_style (widget);
window = gtk_widget_get_window (widget);
+ gtk_widget_get_allocation (widget, &allocation);
- gtk_paint_layout (style,
- window,
+ x -= allocation.x;
+ y -= allocation.y;
+
+ gtk_cairo_paint_layout (style,
+ cr,
gtk_widget_get_state (widget),
FALSE,
- &event->area,
widget,
"label",
x, y,
gint range[2];
cairo_region_t *clip;
GtkStateType state;
- cairo_t *cr;
range[0] = info->selection_anchor;
range[1] = info->selection_end;
x, y,
range,
1);
- cairo_region_intersect (clip, event->region);
/* FIXME should use gtk_paint, but it can't use a clip
* region
*/
- cr = gdk_cairo_create (event->window);
+ cairo_save (cr);
gdk_cairo_region (cr, clip);
cairo_clip (cr);
cairo_move_to (cr, x, y);
_gtk_pango_fill_layout (cr, priv->layout);
- cairo_destroy (cr);
+ cairo_restore (cr);
cairo_region_destroy (clip);
}
else if (info)
GdkColor *visited_link_color;
if (info->selectable && gtk_widget_has_focus (widget))
- gtk_label_draw_cursor (label, x, y);
+ gtk_label_draw_cursor (label, cr, x, y);
focus_link = gtk_label_get_focus_link (label);
active_link = info->active_link;
if (active_link)
{
- cairo_t *cr;
-
range[0] = active_link->start;
range[1] = active_link->end;
- cr = gdk_cairo_create (event->window);
-
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ cairo_save (cr);
clip = gdk_pango_layout_get_clip_region (priv->layout,
x, y,
gdk_color_free (link_color);
gdk_color_free (visited_link_color);
- cairo_destroy (cr);
+ cairo_restore (cr);
}
if (focus_link && gtk_widget_has_focus (widget))
1);
cairo_region_get_extents (clip, &rect);
- gtk_paint_focus (style, window, gtk_widget_get_state (widget),
- &event->area, widget, "label",
+ gtk_cairo_paint_focus (style, cr, gtk_widget_get_state (widget),
+ widget, "label",
rect.x, rect.y, rect.width, rect.height);
cairo_region_destroy (clip);